package ACM.lenovo;
import java.util.*;
/**
 * @Author wwk
 * @DATE 2022/8/19 18:48
 */
public class first {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); //size
        while(n-->0){
            String word = scanner.next();
            int len = word.length();
            //长度要至少6
            if(len <6){
                System.out.println("NO");
                break;
            }
            int num = 0;
            boolean flag = true;
            int count = 0;  //计数字母数量
            for (int i = 0; i < len; i++) {

                //没有连续两个字符一摸一样
                if(i>0 && word.charAt(i) == word.charAt(i-1)){
                    flag = false;

                }
                //没有连续5个字符为字母
                if(Character.isLetter(word.charAt(i))){
                    count++;
                    if(flag && count>=5){
                        flag = false;
                    }
                }else{
                    count=0;
                }
                if(Character.isDigit(word.charAt(i))){
                    num++;
                }
            }
            //数字数量不能大于字母
            if(flag && num >= len-num){
                flag = false;
            }

            if (flag){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }


    }
}
